# Table 3

rm(list=ls(all=TRUE))

require(MASS)
require(stargazer)

#### Datasets ####
setwd("/Users/sebastian/Dropbox/The politics of interruptions - JOP RR/Replication Files/Data Rep")
load("data_empirics_rep.Rdata") 

## Use only observations that where legislators were interrupted:
data_empirics_interruptions <- data_empirics[data_empirics$interruption_final_dummy==1,]  # All interruptions
data_empirics_aggressive <- data_empirics[data_empirics$aggressive_interruption_dummy==1,]  # Aggressive interruptions only
data_empirics_procedural <- data_empirics[data_empirics$time_interruption_dummy==1,]  # Procedural interruptions only

#### MODEL 3.1 - MODEL 3.3: Length of speech before interruption ####

model_3.1 <- glm.nb(length_speech_nocont ~ female_dum + ideology_ext + 
                      committee_chair + seniority + type_member +
                      party_match_pres + 
                      election_year +
                      tot_num_speeches_session_10 + mean_length_leg +
                      negative_lang_w + mujeres_dummy_before +
                      factor(cohort), 
                    data = data_empirics_interruptions)

model_3.2 <- glm.nb(length_speech_nocont ~ female_dum + ideology_ext + 
                      committee_chair + seniority + type_member +
                      party_match_pres + 
                      election_year +
                      tot_num_speeches_session_10 + mean_length_leg +
                      negative_lang_w + mujeres_dummy_before + 
                      factor(cohort), 
                    data = data_empirics_procedural)

model_3.3 <- glm.nb(length_speech_nocont ~ female_dum + ideology_ext + 
                      committee_chair + seniority + type_member +
                      party_match_pres + 
                      election_year +
                      tot_num_speeches_session_10 + mean_length_leg +
                      negative_lang_w + mujeres_dummy_before + 
                      factor(cohort), 
                    data = data_empirics_aggressive)

#### TABLE 3: Length of speech before interruption ####
setwd("/Users/sebastian/Dropbox/The politics of interruptions - JOP RR/Replication Files/Table")

stargazer(model_3.1,model_3.2,model_3.3,
          type = "html", style = "ajps", out = "table3.html",
          covariate.labels = c("Woman","Ideological Extremism","Committee Chair",
                               "Seniority","National MC","Same Party as Leg. Pres.",
                               "Election Year", "Speeches during Debate",
                               "Mean Length of MC Speech", "Negative Language (Speech)",
                               "Topic: Women"),
          omit = "factor",
          no.space=TRUE,
          dep.var.labels=c("Interruptions (All)","Procedural Interruptions", "Aggressive Interruptions"),
          digits=3,
          df = FALSE,
          keep.stat = c("theta", "n"))